#define _CRT_SECURE_NO_WARNINGS 1
#include"BTNode.h"
void PreOrder(BTNode* root)
{
	if (root == NULL){
		printf("NULL ");
		return;
	}
	printf("%c ", root->data);
	PreOrder(root->left);
	PreOrder(root->right);

}
void InOrder(BTNode* root)
{
	if (root == NULL){
		printf("NULL ");
		return;
	}
	InOrder(root->left);
	printf("%c ", root->data);

	InOrder(root->right);
}
void PostOrder(BTNode* root)
{
	if (root == NULL){
		printf("NULL ");
		return;
	}

	PostOrder(root->left);
	PostOrder(root->right);
	printf("%c ", root->data);


}
void CreatTreeNode(BTNode* &T)
{
	BTDataType ch;
	scanf("%c", &ch);
	if (ch == '#'){
		T = NULL;
		return;
	}
	else{
		T = (BTNode*)malloc(sizeof(BTNode));
		if (!T)
		{
			exit(-1);

		}

		T->data = ch;
	}
	CreatTreeNode(T->left);
	CreatTreeNode(T->right);
}
int LeafCount(BTNode* T)
{
	if (!T) return 0;
	else
	if (!T->left&&!T->right) return 1;
	else
		return LeafCount(T->left) + LeafCount(T->right);
}
int  CountNodes(BTNode* T)
{
	if (!T) return 0;
	else
	{
		return CountNodes(T->left) + CountNodes(T->right) + 1;
	}
}
int Height(BTNode* T)
{
	int leftcount = 0;
	int rightcount = 0;
	if (!T){
		return 0;
	}
	else
	{
		leftcount = Height(T->left);
		leftcount = Height(T->right);
		return (leftcount > rightcount) ? (leftcount + 1) : (rightcount + 1);
	}
}
